﻿/*jqgrid 自定义编辑类型.规则:初始化一律init开头.获取值一律get开头*/
/*数据类型*/
function initselect(list, selectvalue) {
    var html = [];
    html.push("<select style='width:99%;border:0;'>");
    for (var i in list) {
        var v = "";
        var t = "";
        if (typeof (list[i]) == "string")
            t = v = list[i];
        else if (typeof (list[i]) == "object") {
            v = list[i][0];
            t = list[i][0];
        }
        html.push("<option value='" + v + "' " + (v == selectvalue ? "selected" : "") + ">" + t + "</option>");

    }
    html.push("</select>");
    return $(html.join(""));
}
function initDbType(d, e) {
    var obj = null;
    if (!window.DbTypeList) {
        $.ajax({ "url": "/Tools/JSON.ashx?param=db&type=info&act=getdbtypelist", dataType: "json", async: false, success: function (data) {
            window.DbTypeList = data;
        }
        });
    }
    obj = initselect(window.DbTypeList, d);
    return obj;
}
function getDbType(d, e, f) {
    return d.val();
}
//获取表的字段名
function initDbField(d, e) {
    var obj = null;
    if (!window.DbFieldList) {
        $.ajax({ "url": "/Tools/JSON.ashx?param=db&type=info&act=getcolumns&tablename=" + e.tablename, dataType: "json", async: false, success: function (data) {
            window.DbFieldList = data;
        }
        });
    }
    obj = initselect(window.DbFieldList, d);
    return obj;
}
function getDbField(d, e, f) {
    return d.val();
}